import os
import shutil

# 将当前目录下的所有子目录下的txt文件移动到 目标目录下
def copy_files_to_target_dir(source_dir, target_dir):
    for root, dirs, files in os.walk(source_dir):
        for file in files:
            if file.endswith(".txt"):
                source_file_path = os.path.join(root, file)
                target_file_path = os.path.join(target_dir, file)
                shutil.copy2(source_file_path, target_file_path)
                print(f"Copied: {source_file_path} to {target_file_path}")

# Set the source directory as the current working directory
source_directory = os.getcwd()

# Set the target directory
target_directory = "../ds"

# Call the function to copy the files
copy_files_to_target_dir(source_directory, target_directory)
